<!DOCTYPE html>
<html>
<head>
    <title>菜单功能管理</title>
<#include "../common/common.ftl"/>
</head>
<body>
<div class="layui-fluid">
    <div class="layui-row layui-col-space10">
        <div class="layui-col-md2">
            <div class="layui-card">
                <div class="layui-card-header">房源信息</div>
                <div class="layui-card-body">
                    <div class="layui-row">
                        <ul id="treeMenu"></ul>
                    </div>
                </div>
            </div>
        </div>
        <div class="layui-col-md10">
            <div class="layui-card">
                <div class="layui-card-header">
                    楼盘图
                    <span style="padding-left: 15px;" id="buildingInfo"></span>
                    <span style="position: absolute;right: 30px;">
                        <#if dataDictList?? && dataDictList?size gt 0>
                    <#list dataDictList as dataDict>
                    <span class="layui-badge" style="background-color: ${(dataDict.color)!}">&nbsp;${(dataDict.name)!}&nbsp;</span>
                    </#list>
                        </#if>
                    </span>
                </div>
                <div class="layui-card-body" id="housePictureArea">
                </div>
            </div>
        </div>
    </div>
</div>
<script src="/layui/layui.js" charset="utf-8"></script>
<script src="/modules/business/house.js" charset="utf-8"></script>
<script>
    layui.config({
        base: '/modules/' //静态资源所在路径
    }).use(["tree", "jquery", "jmdf"], function () {
        var tree = layui.tree, $ = layui.jquery, jmdf = layui.jmdf;

        $.ajax({
            url: "loadTreeData",
            type: "post",
            data: {_t: new Date().getTime()},
            success: function (data) {
                var option = {
                    elem: '#treeMenu' //传入元素选择器
                    , nodes: [data],
                    click: function (node) {
                        onClick(node);
                    }
                };
                tree(option);
            }
        });

        function onClick(node) {
            var id = node.id;//id
            if (id == null || id == "")
                return;
            var buildNum = node.name;//buildNum
            loadHousePicture(id, buildNum);
        }

        //查询楼盘图数据
        function loadHousePicture(id, buildNum) {
            $.ajax({
                url: "loadHousePicture",
                type: "post",
                data: {azProjectId: id, buildNum: buildNum, _t: new Date().getTime()},
                success: function (data) {
                    var azProject = data.azProject;
                    $("#buildingInfo").text(azProject.projectName + buildNum + "号楼");
                    var pictureHtml = "";
                    pictureHtml = getPicture(data);
                    $("#housePictureArea").html(pictureHtml);
                    $(".houseStyle").click(function () {
                        var houseId = $(this).attr("id");
                        var houseStatus = $(this).attr("houseStatus");
                        if (houseStatus == 2) {
                            layer.msg("已选房源不能修改", {anim: 0, icon: 2, time: 1000});
                            return;
                        }
                        jmdf.minForm("updateHouseStatus?houseId=" + houseId, "500px", "280px")
                    })
                }
            });
        }

        window.loadHousePicture = loadHousePicture;
    });
</script>
</body>
</html>